import Filter from '@src/filter/filter.js';
import RenderCell from 'packages/BaseTableCell/renderCell.js';
import formatColumn from 'packages/BaseTableCell/formatColumn';
import { isUndefined } from '@src/util/type'
import { isCalendar } from '@src/util/CalendarUtil';
import { Inquire } from '../../list/TaskFieldModel'
import i18n from '@src/locales'
import { 
  isNotSupportedDisplayField, 
  isSystemFiled, 
} from '@service/FieldService'

const inquireMap = {}
Inquire.forEach(field => {
  field.show = true; 
  inquireMap[field.fieldName] = field; 
})

// 导出列选项
export const allExport = [
  {
    exportAlias: "state",
    displayName: i18n.t('task.taskState'),
  },
  {
    exportAlias: "createUser",
    displayName: i18n.t('common.base.createUser'),
  },
  {
    exportAlias: "allotUser",
    displayName: i18n.t('task.allotUser'),
  },
  {
    exportAlias: "reAllotUser",
    displayName: i18n.t('task.reAllotUsers')
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "executorName",
    exportAlias: "executor",
    displayName: i18n.t('task.executor'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "executorTag",
    exportAlias: "executorTag",
    displayName: i18n.t('task.list.displayName.departmentOfExecutor'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "synergies",
    exportAlias: "synergies",
    displayName: i18n.t('task.synergies'),
    formType: "user",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "createTime",
    exportAlias: "createTime",
    displayName: i18n.t('common.base.createTime'),
    formType: "datetime",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "allotTime",
    exportAlias: "allotTime",
    displayName: i18n.t('task.list.displayName.allotTime'),
    formType: "datetime",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "acceptTime",
    exportAlias: "acceptTime",
    displayName: i18n.t('task.list.displayName.acceptTime'),
    formType: "datetime",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "startTime",
    exportAlias: "startTime",
    displayName: i18n.t('task.list.displayName.startTime'),
    formType: "datetime",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "completeTime",
    exportAlias: "completeTime",
    displayName: i18n.t('common.base.completeTime'),
    formType: "datetime",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "allotType",
    exportAlias: "allotType",
    displayName: i18n.t('task.list.displayName.allotType'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "acceptUsedTimeStr",
    displayName: i18n.t('task.detail.components.acceptTime'),
    exportAlias: "acceptUsedTime",
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "taskUsedTimeStr",
    exportAlias: "taskUsedTime",
    displayName: i18n.t('task.detail.components.taskTime'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "workUsedTimeStr",
    exportAlias: "workUsedTime",
    displayName: i18n.t('task.detail.components.workTime'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "taskResponseTimeStr",
    exportAlias: "taskResponseTime",
    displayName: i18n.t('task.detail.components.respondTime'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "onceOverTime",
    exportAlias: "onceOverTime",
    displayName: i18n.t('common.task.exceptionStatus.onceOverTime'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "onceRefused",
    exportAlias: "onceRefused",
    displayName: i18n.t('common.task.exceptionStatus.onceRefused'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "oncePaused",
    exportAlias: "oncePaused",
    displayName: i18n.t('common.task.exceptionStatus.oncePaused'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "onceRollback",
    exportAlias: "onceRollback",
    displayName: i18n.t('common.task.exceptionStatus.onceRollback'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "onceReallot",
    exportAlias: "onceReallot",
    displayName: i18n.t('common.task.exceptionStatus.onceAllot'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "oncePrinted",
    exportAlias: "oncePrinted",
    displayName: i18n.t('task.list.displayName.oncePrinted'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "positionException",
    exportAlias: "positionException",
    displayName: i18n.t('common.task.exceptionStatus.positionException'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  // {
  //   id: 5460,
  //   tableName: "customer",
  //   isSystem: 0,
  //   fieldName: "paymentMethod",
  //   exportAlias: "paymentMethod",
  //   displayName: "支付方式",
  //   formType: "text",
  //   defaultValue: null,
  //   isNull: 1,
  //   isSearch: 1,
  //   placeHolder: null,
  //   setting: {},
  //   orderId: 1,
  //   isDelete: 0,
  //   guideProfessions: [],
  //   show: true,
  //   isGuideData: false,
  //   guideData: false,
  // },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "reviewTime",
    exportAlias: "reviewTime",
    displayName: i18n.t('task.detail.components.reviewTime'),
    formType: "datetime",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "closeTime",
    exportAlias: "closeTime",
    displayName: i18n.t('task.list.displayName.closeTime'),
    formType: "datetime",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
  {
    id: 5460,
    tableName: "customer",
    isSystem: 1,
    fieldName: "updateTime",
    exportAlias: "updateTime",
    displayName: i18n.t('task.list.displayName.updateTime'),
    formType: "text",
    defaultValue: null,
    isNull: 1,
    isSearch: 1,
    placeHolder: null,
    setting: {},
    orderId: 1,
    isDelete: 0,
    guideProfessions: [],
    show: true,
    isGuideData: false,
    guideData: false,
  },
]

// 高级搜索
export const getAdvancedFields = (vm) => {
  const that = vm
  const customerField = that.customerField || {}
  const customerOption = customerField?.setting?.customerOption || {}
  const systemFieldSetting = that.systemFieldSetting || {}
  // const isCalendar = JSON.parse(localStorage.getItem('isCalendar'))
  
  return [
    {
      displayName: i18n.t('common.task.taskType'),
      fieldName: 'taskType',
      formType: 'select',
      setting: {
        isMulti: false,
        dataSource: that.taskTypeList
      },
    },
    {
      fieldName: 'tags',
      displayName: i18n.t('task.list.displayName.chooseTag'),
      formType: 'select',
    },
    {
      fieldName: 'customer',
      displayName: i18n.t('common.base.customer'),
      formType: 'text',
    },
    {
      fieldName: 'tlmName',
      displayName: i18n.t('common.base.contact'),
      formType: 'select',
      show: customerOption.linkman
    },
    {
      fieldName: 'area',
      exportAlias: 'customerAddress',
      displayName: i18n.t('task.list.displayName.area'),
      formType: 'address',
      show: customerOption.address
    },
    {
      fieldName: 'cusAddress',
      displayName: i18n.t('task.list.displayName.detailAddress'),
      formType: 'text',
      show: customerOption.address
    },
    {
      fieldName: 'product',
      displayName: i18n.t('common.base.product'),
      formType: 'text',
      show: customerOption.product
    },
    {
      fieldName: 'serviceType',
      displayName: i18n.t('common.form.type.serviceType'),
      formType: 'select',
      show: systemFieldSetting.hasServiceType,
      setting: {
        dataSource: that.serviceTypeField?.setting?.dataSource || []
      }
    },
    {
      fieldName: 'serviceContent',
      displayName: i18n.t('common.form.type.serviceContent'),
      formType: 'select',
      show: systemFieldSetting.hasServiceContent,
      setting: {
        dataSource: that.serviceContentField?.setting?.dataSource || []
      }
    },
    {
      fieldName: 'level',
      displayName: i18n.t('common.form.type.level'),
      formType: 'select',
      show: systemFieldSetting.hasLevel,
      setting: {
        dataSource: that.levelField?.setting?.dataSource || []
      }
    },
    {
      fieldName: 'description',
      displayName: i18n.t('common.form.type.description'),
      formType: 'description',
      show: systemFieldSetting.hasDescription
    },
    {
      fieldName: 'paymentMethod',
      displayName: i18n.t('task.detail.components.payMethod'),
      formType: 'select',
      show: that.paymentConfig?.version === 1,
      setting: {
        isMulti: false, 
        dataSource: [
          {
            text: i18n.t('task.detail.components.onlinePayByAli'),
            value: '在线支付-支付宝'
          },
          {
            text: i18n.t('task.detail.components.aliPayCode'),
            value: '支付宝收款码'
          },
          {
            text: i18n.t('task.detail.components.weChatCode'),
            value: '微信收款码'
          },
          {
            text: i18n.t('task.detail.components.bankCardCollection'),
            value: '银行卡收款'
          },
          {
            text: i18n.t('task.detail.components.otherPayUnifiedCollection'),
            value: '其他支付-统一收款'
          },
          {
            text: i18n.t('task.detail.components.otherPayMonthCollection'),
            value: '其他支付-月结'
          },
          {
            text: i18n.t('task.detail.components.otherPayWeekCollection'),
            value: '其他支付-周结'
          },
        ]
      }
    },
    {
      fieldName: 'createUser',
      displayName: i18n.t('common.base.createUser'),
      formType: 'user',
      defineType: []
    },
    {
      fieldName: 'executor',
      displayName: i18n.t('task.executor'),
      formType: 'user',
      defineType: []
    },
    {
      fieldName: 'synergyId',
      displayName: i18n.t('task.synergies'),
      formType: 'user',
      defineType: []
    },
    inquireMap.state,
    {
      fieldName: 'balanceUser',
      displayName: i18n.t('task.list.displayName.reckoner'),
      formType: 'user',
      defineType: []
    },
    {
      isSystem: 1,
      fieldName: 'createTime',
      displayName: i18n.t('common.base.createTime'),
      formType: 'datetime',
      orderId: 1,
    },
    {
      fieldName: 'allotTime',
      displayName: i18n.t('task.list.displayName.allotTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'acceptTime',
      displayName: i18n.t('task.list.displayName.acceptTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'startTime',
      displayName: i18n.t('task.list.displayName.startTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'completeTime',
      displayName: i18n.t('common.base.completeTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'balanceTime',
      displayName: i18n.t('task.list.displayName.balanceTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'planTime',
      displayName: i18n.t('common.form.type.planTime'),
      formType: 'datetime',
      show: !isCalendar
    },
    {
      fieldName: 'planStartTime',
      displayName: i18n.t('common.form.type.planStartTime'),
      formType: 'datetime',
      show: isCalendar
    },
    {
      fieldName: 'planEndTime',
      displayName: i18n.t('common.form.type.planEndTime'),
      formType: 'datetime',
      show: isCalendar
    },
    {
      fieldName: 'reviewTime',
      displayName: i18n.t('task.detail.components.reviewTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'closeTime',
      displayName: i18n.t('task.list.displayName.closeTime'),
      formType: 'datetime',
    },
    inquireMap.allotTypeStr,
    inquireMap.onceException,
    inquireMap.onceReallot,
    inquireMap.oncePrinted,
    {
      fieldName: 'updateTime',
      displayName: i18n.t('task.list.displayName.updateTime'),
      formType: 'datetime',
    },
    inquireMap.inApprove,
  ].map(item => {
    return {
      ...item,
      setting: item.setting || {},
      defaultValue: null,
      show: isUndefined(item.show) ? true : item.show,
      isSearch: 1,
      isNull: 1,
      isSystem: 1,
      orderId: 1
    }
  });
}


// 列表 && 选择列
export const getColumnFields = (vm) => {
  const that = vm
  const customerField = that.customerField || {}
  const customerOption = customerField?.setting?.customerOption || {}
  // const isCalendar = JSON.parse(localStorage.getItem('isCalendar'))
  
  const fields = [
    {
      fieldName: 'taskNo',
      displayName: i18n.t('common.form.type.taskNo'),
      formType: 'text',
      renderCell: (h, col, row) => {
        // let taskId = row.id;
        // let taskNo = row[col.field]
        // return RenderCell.renderTask.call(that, h, taskNo, taskId, true);
        return RenderCell.renderTask.call(that, h, row, that.allowTaskViewDetail);
      }
    },
    {
      displayName: i18n.t('common.task.taskType'),
      fieldName: 'taskType',
      formType: 'select',
      renderCell: (h, col, row) => {
        return (<div>{row.templateName || ''}</div>)
      }
    },
    {
      fieldName: 'customer',
      displayName: i18n.t('common.base.customer'),
      formType: 'text',
      renderCell: (h, col, row) => {
        let displayName = row['customerEntity'] && row['customerEntity'].name;
        let customerId = row?.customerEntity?.id;
        return RenderCell.renderCustomer.call(that, h, displayName, customerId, true)
      }
    },
    {
      fieldName: 'tlmName',
      displayName: i18n.t('common.base.contact'),
      formType: 'select',
      show: customerOption.linkman,
      visibleForSelectColumn: customerOption.linkman,
      renderCell: (h, col, row) => {
        return (<div>
          { row['linkMan'] && row['linkMan'].name }
        </div>)
      }
    },
    {
      fieldName: 'tlmPhone',
      displayName: i18n.t('common.base.phone'),
      formType: 'select',
      show: customerOption.linkman,
      visibleForSelectColumn: customerOption.linkman,
      renderCell: (h, col, row) => {
        return (<div>
          { row['linkMan'] && row['linkMan'].phone }
        </div>)
      }
    },
    {
      fieldName: 'area',
      displayName: i18n.t('common.form.type.customerAddress'),
      formType: 'address',
      show: customerOption.address,
      visibleForSelectColumn: customerOption.address,
      renderCell: (h, col, row) => {
        return (<div>{Filter.prettyAddress(row[col.formType])}</div>)
      }
    },
    {
      fieldName: 'product',
      displayName: i18n.t('common.base.product'),
      formType: 'text',
      show: customerOption.product,
      visibleForSelectColumn: customerOption.product,
      renderCell: (h, col, row) => {
        return row.products
        && row.products.map((product) => product.name).join(', ')
      }
    },
    {
      fieldName: 'level',
      displayName: i18n.t('common.form.type.level'),
      formType: 'select',
    },
    {
      fieldName: 'serviceType',
      displayName: i18n.t('common.form.type.serviceType'),
      formType: 'select',
    },
    {
      fieldName: 'serviceContent',
      displayName: i18n.t('common.form.type.serviceContent'),
      formType: 'select',
    },
    {
      fieldName: 'paymentMethod',
      displayName: i18n.t('task.detail.components.payMethod'),
      formType: 'select',
      show: that.paymentConfig?.version == 1,
      renderCell: (h, col, row) => {
        return (row.attribute && row.attribute.paymentMethod)
      }
    },
    {
      fieldName: 'planTime',
      displayName: i18n.t('common.form.type.planTime'),
      formType: 'datetime',
      show: !isCalendar,
      visibleForSelectColumn: !isCalendar
    },
    {
      fieldName: 'planStartTime',
      displayName: i18n.t('common.form.type.planStartTime'),
      formType: 'datetime',
      show: isCalendar,
      visibleForSelectColumn: isCalendar,
    },
    {
      fieldName: 'planEndTime',
      displayName: i18n.t('common.form.type.planEndTime'),
      formType: 'datetime',
      show: isCalendar,
      visibleForSelectColumn: isCalendar
    },
    {
      fieldName: 'description',
      displayName: i18n.t('common.form.type.description'),
      formType: 'description',
    },
    {
      fieldName: 'createUserName',
      displayName: i18n.t('common.base.createUser'),
      formType: 'user'
    },
    {
      fieldName: 'executorName',
      displayName: i18n.t('task.executor'),
      formType: 'user'
    },
    {
      fieldName: 'synergies',
      displayName: i18n.t('task.synergies'),
      formType: 'user',
    },
    {
      fieldName: 'reAllotUserList',
      displayName: i18n.t('task.reAllotUsers'),
      renderCell: (h, col, row) => {
        const reAllotUserName = row?.reAllotUserList?.map(item => item.displayName).join(', ')
        return (<div>{reAllotUserName || ''}</div>);
      }
    },
    {
      fieldName: 'state',
      displayName: i18n.t('task.taskState'),
      formType: 'text',
    },
    {
      fieldName: 'createTime',
      displayName: i18n.t('common.base.createTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'allotTime',
      displayName: i18n.t('task.list.displayName.allotTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'acceptTime',
      displayName: i18n.t('task.list.displayName.acceptTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'startTime',
      displayName: i18n.t('task.list.displayName.startTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'completeTime',
      displayName: i18n.t('common.base.completeTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'balanceTime',
      displayName: i18n.t('task.list.displayName.balanceTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'reviewTime',
      displayName: i18n.t('task.detail.components.reviewTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'closeTime',
      displayName: i18n.t('task.list.displayName.closeTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'balanceConfirm',
      displayName: i18n.t('task.detail.components.settlementState'),
      formType: 'text',
    },
    {
      fieldName: 'balanceUser',
      displayName: i18n.t('task.list.displayName.reckoner'),
      formType: 'user',
    },
    {
      fieldName: 'allotTypeStr',
      displayName: i18n.t('task.list.displayName.allotType'),
      formType: 'select',
      renderCell: (h, col, row) => {
        let allotTypeText = {
          1: i18n.t('task.detail.components.manualDispatch'),
          2: i18n.t('task.detail.components.poolDispatch'),
          3: i18n.t('task.detail.components.autoDispatch')
        };
        return (<div>{allotTypeText[row.allotType] || ''}</div>);
      }
    },
    {
      fieldName: 'acceptUsedTimeStr',
      displayName: i18n.t('task.detail.components.acceptTime'),
      formType: 'text',
    },
    {
      fieldName: 'taskUsedTimeStr',
      displayName: i18n.t('task.detail.components.taskTime'),
      formType: 'text',
    },
    {
      fieldName: 'workUsedTimeStr',
      displayName: i18n.t('task.detail.components.workTime'),
      formType: 'text',
    },
    {
      fieldName: 'taskResponseTimeStr',
      displayName: i18n.t('task.detail.components.respondTime'),
      formType: 'text',
    },
    {
      fieldName: 'onceOverTime',
      displayName: i18n.t('common.task.exceptionStatus.onceOverTime'),
      formType: 'select',
      renderCell: (h, col, row) => {
        return RenderCell.renderBoolean(h, row[col.field]);
      }
    },
    {
      fieldName: 'onceRefused',
      displayName: i18n.t('common.task.exceptionStatus.onceRefused'),
      formType: 'select',
      renderCell: (h, col, row) => {
        return RenderCell.renderBoolean(h, row[col.field]);
      }
    },
    {
      fieldName: 'oncePaused',
      displayName: i18n.t('common.task.exceptionStatus.oncePaused'),
      formType: 'select',
      renderCell: (h, col, row) => {
        return RenderCell.renderBoolean(h, row[col.field]);
      }
    },
    {
      fieldName: 'onceRollback',
      displayName: i18n.t('common.task.exceptionStatus.onceRollback'),
      formType: 'select',
      renderCell: (h, col, row) => {
        return RenderCell.renderBoolean(h, row[col.field]);
      }
    },
    {
      fieldName: 'onceReallot',
      displayName: i18n.t('common.task.exceptionStatus.onceAllot'),
      formType: 'select',
      renderCell: (h, col, row) => {
        return RenderCell.renderBoolean(h, row[col.field]);
      }
    },
    {
      fieldName: 'oncePrinted',
      displayName: i18n.t('task.list.displayName.oncePrinted'),
      formType: 'select',
      renderCell: (h, col, row) => {
        return RenderCell.renderBoolean(h, row[col.field]);
      }
    },
    {
      fieldName: 'positionException',
      displayName: i18n.t('common.task.exceptionStatus.positionException'),
      formType: 'select',
      renderCell: (h, col, row) => {
        return RenderCell.renderBoolean(h, row[col.field]);
      }
    },
    {
      fieldName: 'updateTime',
      displayName: i18n.t('task.list.displayName.updateTime'),
      formType: 'datetime',
    },
    {
      fieldName: 'sparePartsPrice',
      displayName: i18n.t('task.detail.components.sparePartFee'),
      formType: 'text',
    },
    {
      fieldName: 'servicePartsPrice',
      displayName: i18n.t('task.detail.components.serviceFee'),
      formType: 'text',
    },
    {
      fieldName: 'discount',
      displayName: i18n.t('task.detail.components.discountFee'),
      formType: 'text',
    },
    {
      fieldName: 'totalPrice',
      displayName: i18n.t('task.detail.components.totalExpense'),
      formType: 'text',
    },
    {
      fieldName: 'totalCost',
      displayName: i18n.t('task.list.displayName.cost'),
      formType: 'text',
    },
    {
      fieldName: 'totalProfit',
      displayName: i18n.t('task.list.displayName.profit'),
      formType: 'text',
    },
    {
      fieldName: 'balanceOperation',
      displayName: i18n.t('common.base.operation'),
      formType: 'text',
      fixed: 'right',
      width: '88px',
      show: 'important'
    }
  ]
  
  return fields.map(item => {
    // 初始化属性
    let field = {
      ...item,
      setting: item.setting || {},
      isSystem: 1,
      isNull: 1,
      isSearch: 1,
      orderId: 1,
      show: isUndefined(item.show) ? true : item.show,
      visibleForSelectColumn: isUndefined(item.visibleForSelectColumn) ? true : item.visibleForSelectColumn,
    };
    return formatColumn(field); 
  })
};

// 除了工单以外的其他结算列表的字段
export const otherBalanceFields = [{
  tableName: 'balance',
  isSystem: 1,
  fieldName: 'orderNo',
  displayName: i18n.t('common.fields.orderSerialNumber.displayName'),
  formType: 'text',
  defaultValue: null,
  isNull: 0,
  isSearch: 0,
  placeHolder: i18n.t('task.taskTypes.balance.placeHolder1'),
  setting: {},
  show: true,
  isMallShow: true,
  isPaasShow: false,
  export: true,
  orderId: 0,
  isDelete: 0,
  isEdit: 1,
  disabled: 1,
}, {
  tableName: 'balance',
  isSystem: 1,
  fieldName: 'serialNo',
  displayName: i18n.t('common.base.serialNumber'),
  formType: 'text',
  defaultValue: null,
  isNull: 0,
  isSearch: 0,
  placeHolder: i18n.t('member.list.title10'),
  setting: {},
  show: true,
  isMallShow: false,
  isPaasShow: true,
  export: true,
  orderId: 0,
  isDelete: 0,
  isEdit: 1,
  disabled: 1,
}, {
  tableName: 'balance',
  isSystem: 1,
  fieldName: 'customer',
  displayName: i18n.t('common.base.systemKeyword.customer'),
  formType: 'customer',
  defaultValue: null,
  isNull: 0, 
  isSearch: 0,
  placeHolder: i18n.t('product.form.placeholder.customerCheck'),
  setting: {},
  orderId: 1, 
  isDelete: 0,
  show: true, 
  isMallShow: true,
  isPaasShow: true,
  export: true, 
  isEdit: 1, 
  disabled: 1,
}, {
  tableName: 'balance',
  isSystem: 1,
  fieldName: 'consignee',
  displayName: i18n.t('order.component.consignee'),
  formType: 'text',
  defaultValue: null,
  isNull: 0, 
  isSearch: 0,
  placeHolder: i18n.t('order.placeHolder.enterConsignee'),
  setting: {},
  orderId: 2, 
  isDelete: 0,
  show: true, 
  isMallShow: true,
  isPaasShow: false,
  export: true, 
  isEdit: 1, 
  disabled: 1,
}, {
  tableName: 'balance',
  isSystem: 1,
  fieldName: 'consigneePhone',
  displayName: i18n.t('task.taskTypes.balance.consigneePhone'),
  formType: 'phone',
  defaultValue: null,
  isNull: 0,
  isSearch: 1,
  placeHolder: i18n.t('task.taskTypes.balance.enterConsigneePhone'),
  setting: {},
  orderId: 3,
  isDelete: 0,
  isEdit: 1,
  show: true,
  isMallShow: true,
  isPaasShow: false,
  export: true,
  disabled: 1,
}, {
  tableName: 'balance',
  isSystem: 1,
  fieldName: 'amountPaid',
  displayName: i18n.t('order.detailV2.amountPaid'),
  formType: 'number',
  defaultValue: null,
  isNull: 0, 
  isSearch: 0,
  placeHolder: i18n.t('common.placeholder.input2'),
  setting: {},
  orderId: 4, 
  isDelete: 0,
  show: true, 
  isMallShow: true,
  isPaasShow: true,
  export: true, 
  isEdit: 1, 
  disabled: 1,
}, {
  tableName: 'balance',
  isSystem: 1,
  fieldName: 'useQuota',
  displayName: i18n.t('task.taskTypes.balance.usageLimit'),
  formType: 'number',
  defaultValue: null,
  isNull: 0, 
  isSearch: 0,
  placeHolder: i18n.t('common.placeholder.input2'),
  setting: {},
  orderId: 5, 
  isDelete: 0,
  show: true, 
  isMallShow: true,
  isPaasShow: true,
  export: true, 
  isEdit: 1, 
  disabled: 1,
}, {
  tableName: 'balance',
  isSystem: 1,
  fieldName: 'balanceStatus',
  displayName: i18n.t('task.detail.components.settlementState'),
  formType: 'select',
  defaultValue: null,
  isNull: 0, 
  isSearch: 0,
  placeHolder: i18n.t('common.placeholder.input2'),
  setting: {
    isMulti: false,
    dataSource: [{
      text: i18n.t('common.base.all'),
      value: 0,
    }, {
      text: i18n.t('common.task.status.settled'),
      value: 1,
    }, {
      text: i18n.t('common.task.status.unBalanced'),
      value: 2,
    }],
  },
  orderId: 6, 
  isDelete: 0,
  show: true, 
  isMallShow: true,
  isPaasShow: true,
  export: true, 
  isEdit: 1, 
  disabled: 1,
}, {
  tableName: 'balance',
  isSystem: 1,
  fieldName: 'orderTime',
  displayName: i18n.t('order.detailV2.orderTime'),
  formType: 'datetime',
  defaultValue: null,
  isNull: 0, 
  isSearch: 0,
  placeHolder: null,
  setting: {},
  orderId: 7, 
  isDelete: 0,
  show: true, 
  isMallShow: true,
  isPaasShow: false,
  export: true, 
  isEdit: 1, 
  disabled: 1,
}, {
  tableName: 'balance',
  isSystem: 1,
  fieldName: 'createTime',
  displayName: i18n.t('common.label.createTime'),
  formType: 'datetime',
  defaultValue: null,
  isNull: 0, 
  isSearch: 0,
  placeHolder: null,
  setting: {},
  orderId: 7, 
  isDelete: 0,
  show: true, 
  isMallShow: false,
  isPaasShow: true,
  export: true, 
  isEdit: 1, 
  disabled: 1,
}, {
  tableName: 'balance',
  isSystem: 1,
  fieldName: 'balanceTime',
  displayName: i18n.t('task.list.displayName.balanceTime'),
  formType: 'datetime',
  defaultValue: null,
  isNull: 0, 
  isSearch: 0,
  placeHolder: null,
  setting: {},
  orderId: 7, 
  isDelete: 0,
  show: true, 
  isMallShow: true,
  isPaasShow: true,
  export: true, 
  isEdit: 1, 
  disabled: 1,
}]
